--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION.
--Data Schema For Version 0.0.0.0
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionDelete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionDelete]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionDelete]
(
	@Original_RegionID Int
)
AS
SET NOCOUNT OFF;

DELETE FROM 
	[Region] 
WHERE 
	[RegionID] = @Original_RegionID ;

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelectByRegionPks]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelectByRegionPks]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO


CREATE PROCEDURE [dbo].[gen_RegionSelectByRegionPks]
(
	@xml ntext
)
AS

DECLARE @hDoc int
EXEC sp_xml_preparedocument @hDoc OUTPUT, @xml

SELECT
		[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]

FROM 
[Region]
WHERE

	[Region].[RegionID] IN (SELECT [RegionID] 
											FROM OpenXML(@hDoc, '//Region', 2) 
											WITH ([RegionID] char(36) 'RegionID')) 


exec sp_xml_removeDocument @hDoc

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelectByRegionSinglePk]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelectByRegionSinglePk]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionSelectByRegionSinglePk]
(
	@RegionID Int
)
AS

SELECT 
	[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]

FROM
[Region]
WHERE 
[Region].[RegionID] = @RegionID 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionInsert]
GO

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[gen_RegionInsert]
(
	@RegionID Int = default,
	@RegionDescription NChar(50) = default,
	@created_date datetime,
	@created_by varchar (50),
	@modified_by varchar (50)

)
AS
SET NOCOUNT OFF;

if (@created_date IS NULL)
SET @created_date = GetDate()

INSERT INTO [Region]
(
[RegionDescription],
[RegionID],
[created_date],
[created_by],
[modified_date],
[modified_by]

)
VALUES
(
	@RegionDescription,
	@RegionID,
	@created_date,
	@created_by,
	@created_date,
	@modified_by

);


SELECT 
	[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]

FROM
[Region]
WHERE
	[Region].[RegionID] = @RegionID;
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionPagingSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionPagingSelect]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionPagingSelect]
(
	@page int, -- page number selected by the user
	@pageSize int, -- number of items on the page
	@orderByColumn varchar(100), -- name of column to order things by
	@ascending bit, -- order column ascending or descending
	@filter varchar(100) = null, -- filter statement passed in to determine like criteria on order by column
	@count int out -- number of items in the collection
)
AS

SET NOCOUNT ON;


CREATE TABLE #tmpTable
(
[RegionID] Int
)

DECLARE @total__ivqatedr int
DECLARE @orderByColumnIndex int
-- remove top x values from the temp table based upon the specific page requested
SET @total__ivqatedr = (@pageSize * @page)
IF (@total__ivqatedr <> 0)
BEGIN
	SET ROWCOUNT @total__ivqatedr
END
INSERT INTO #tmpTable
(
	[regionid]
)
SELECT
	[Region].[regionid]
FROM
[Region]
WHERE
	(@orderByColumn = 'RegionID' and (((@filter is null) or ([Region].[RegionID] is null)) or (@filter is not null and [Region].[RegionID] = @filter)))
or
	(@orderByColumn = 'RegionDescription' and (((@filter is null) or ([Region].[RegionDescription] is null)) or (@filter is not null and [Region].[RegionDescription] LIKE @filter)))
ORDER BY
	CASE @ascending WHEN 0 THEN CASE @orderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END DESC, 
	CASE @ascending WHEN 1 THEN CASE @orderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END, 
	CASE @ascending WHEN 0 THEN CASE @orderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END DESC, 
	CASE @ascending WHEN 1 THEN CASE @orderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END

-- set @count based on the rows moved in the previous statement
SET ROWCOUNT 0
SET @count = (
SELECT count(*)
FROM
[Region]
WHERE
	(@orderByColumn = 'RegionID' and (((@filter is null) or ([Region].[RegionID] is null)) or (@filter is not null and [Region].[RegionID] = @filter)))
or
	(@orderByColumn = 'RegionDescription' and (((@filter is null) or ([Region].[RegionDescription] is null)) or (@filter is not null and [Region].[RegionDescription] LIKE @filter)))
)

-- remove top x values from the temp table based upon the specific page requested
SET @total__ivqatedr = (@pageSize * @page) - @pageSize
IF (@total__ivqatedr <> 0)
BEGIN
	SET ROWCOUNT @total__ivqatedr
	DELETE FROM #tmpTable
END

-- return the number of rows requested as the page size
SET ROWCOUNT @pageSize
SELECT
	[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]
FROM
	[#tmpTable]
	INNER JOIN [Region] ON #tmpTable.[regionid] = [REGION].[regionid]
ORDER BY
	CASE @ascending WHEN 0 THEN CASE @orderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END DESC, 
	CASE @ascending WHEN 1 THEN CASE @orderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END, 
	CASE @ascending WHEN 0 THEN CASE @orderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END DESC, 
	CASE @ascending WHEN 1 THEN CASE @orderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END

DROP TABLE #tmpTable

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelectBySearchAnd]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelectBySearchAnd]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionSelectBySearchAnd]
(
	@RegionID Int = null, 
	@RegionDescription NChar(50) = null, 
	@paging_PageIndex int = -1, -- page number selected by the user
	@paging_RecordsperPage int = -1, -- number of items on the page
	@paging_OrderByColumn varchar(100) = '', -- name of column to order things by
	@paging_Ascending bit = 1, -- order column ascending or descending
	@paging_Count int out -- number of items in the collection
)
AS

CREATE TABLE #tmpTable 
(
	[RegionID] Int
)

DECLARE @total__ivqatedr int
DECLARE @orderByColumnIndex int
-- remove top x values from the temp table based upon the specific page requested
SET @total__ivqatedr = (@paging_RecordsperPage * @paging_PageIndex)
IF (@total__ivqatedr <> 0) AND (@paging_PageIndex <> -1)
BEGIN
	SET ROWCOUNT @total__ivqatedr
END
INSERT INTO #tmpTable
(
	[regionid]
)
SELECT
	[Region].[regionid]
FROM
[Region]
WHERE
((@RegionID is null) OR ([Region].[RegionID] = @RegionID)) AND
((@RegionDescription is null) OR ([Region].[RegionDescription] LIKE @RegionDescription))
ORDER BY
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END, 
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END

	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END
-- set @paging_Count based on the rows moved in the previous statement
SET ROWCOUNT 0
SET @paging_Count = (
SELECT count(*)
FROM
[Region]
WHERE
((@RegionID is null) OR ([Region].[RegionID] = @RegionID)) AND
((@RegionDescription is null) OR ([Region].[RegionDescription] LIKE @RegionDescription))
)

-- remove top x values from the temp table based upon the specific page requested
SET @total__ivqatedr = (@paging_RecordsperPage * @paging_PageIndex) - @paging_RecordsperPage
IF (@total__ivqatedr <> 0) AND (@paging_PageIndex <> -1)
BEGIN
	SET ROWCOUNT @total__ivqatedr
	DELETE FROM #tmpTable
END

-- return the number of rows requested as the page size
IF (@paging_PageIndex <> -1)
BEGIN
SET ROWCOUNT @paging_RecordsperPage
END
SELECT
	[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]
FROM
	[#tmpTable]
	INNER JOIN [Region] ON #tmpTable.[regionid] = [REGION].[regionid]
ORDER BY
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END, 
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END

	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END
DROP TABLE #tmpTable

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionUpdate]
GO


SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionUpdate]
(
	@RegionDescription NChar(50),
	@modified_by varchar (50),
	@modified_date datetime = null,
	@Original_RegionID Int,
	@Original_time_stamp timestamp

)
AS

IF (@modified_date IS NULL)
SET @modified_date = GetDate();

SET NOCOUNT OFF;
UPDATE 
[Region] 
SET
[RegionDescription] = @RegionDescription,
[modified_by] = @modified_by,
[modified_date] = @modified_date

WHERE
	[Region].[RegionID] = @Original_RegionID AND
	[Region].[time_stamp] = @Original_time_stamp


SELECT
	[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]
FROM 
[Region]
WHERE
	[Region].[RegionID] = @Original_RegionID
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelectByCreatedDateRange]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelectByCreatedDateRange]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionSelectByCreatedDateRange]
(
	@start_date datetime,
	@end_date datetime
)
AS

SET NOCOUNT ON;

SELECT
		[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]

FROM
[Region]
WHERE
((([Region].[created_date] IS NULL) AND (@start_date IS NULL)) OR (@start_date <= [Region].[created_date])) AND 
((([Region].[created_date] IS NULL) AND (@end_date IS NULL)) OR (@end_date >= [Region].[created_date]))
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelectByModifiedDateRange]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelectByModifiedDateRange]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionSelectByModifiedDateRange]
(
	@start_date datetime,
	@end_date datetime
)
AS

SET NOCOUNT ON;

SELECT
		[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]

FROM
[Region]
WHERE
((([Region].[modified_date] IS NULL) AND (@start_date IS NULL)) OR (@start_date <= [Region].[modified_date])) AND 
((([Region].[modified_date] IS NULL) AND (@end_date IS NULL)) OR (@end_date >= [Region].[modified_date]))
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelectBySearchOr]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelectBySearchOr]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionSelectBySearchOr]
(
	@RegionID Int = null, 
	@RegionDescription NChar(50) = null, 
	@paging_PageIndex int = -1, -- page number selected by the user
	@paging_RecordsperPage int = -1, -- number of items on the page
	@paging_OrderByColumn varchar(100) = '', -- name of column to order things by
	@paging_Ascending bit = 1, -- order column ascending or descending
	@paging_Count int out -- number of items in the collection
)
AS

CREATE TABLE #tmpTable 
(
	[RegionID] Int
)

DECLARE @total__ivqatedr int
DECLARE @orderByColumnIndex int
-- remove top x values from the temp table based upon the specific page requested
SET @total__ivqatedr = (@paging_RecordsperPage * @paging_PageIndex)
IF (@total__ivqatedr <> 0) AND (@paging_PageIndex <> -1)
BEGIN
	SET ROWCOUNT @total__ivqatedr
END
INSERT INTO #tmpTable
(
	[regionid]
)
SELECT
	[Region].[regionid]
FROM
[Region]
WHERE
((@RegionID is null) OR ([Region].[RegionID] = @RegionID)) OR
((@RegionDescription is null) OR ([Region].[RegionDescription] LIKE @RegionDescription))
ORDER BY
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END, 
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END

	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END
-- set @paging_Count based on the rows moved in the previous statement
SET ROWCOUNT 0
SET @paging_Count = (
SELECT count(*)
FROM
[Region]
WHERE
((@RegionID is null) OR ([Region].[RegionID] = @RegionID)) OR
((@RegionDescription is null) OR ([Region].[RegionDescription] LIKE @RegionDescription))
)

-- remove top x values from the temp table based upon the specific page requested
SET @total__ivqatedr = (@paging_RecordsperPage * @paging_PageIndex) - @paging_RecordsperPage
IF (@total__ivqatedr <> 0) AND (@paging_PageIndex <> -1)
BEGIN
	SET ROWCOUNT @total__ivqatedr
	DELETE FROM #tmpTable
END

-- return the number of rows requested as the page size
IF (@paging_PageIndex <> -1)
BEGIN
SET ROWCOUNT @paging_RecordsperPage
END
SELECT
	[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]
FROM
	[#tmpTable]
	INNER JOIN [Region] ON #tmpTable.[regionid] = [REGION].[regionid]
ORDER BY
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionID' THEN [Region].[RegionID] END END, 
	CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END DESC, 
	CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'RegionDescription' THEN [Region].[RegionDescription] END END

	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_by' THEN [Region].[created_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'created_date' THEN [Region].[created_date] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_by' THEN [Region].[modified_by] END END
	,CASE @paging_Ascending WHEN 0 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END DESC
	,CASE @paging_Ascending WHEN 1 THEN CASE @paging_OrderByColumn WHEN 'modified_date' THEN [Region].[modified_date] END END
DROP TABLE #tmpTable

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[gen_RegionSelect]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure [dbo].[gen_RegionSelect]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE PROCEDURE [dbo].[gen_RegionSelect]
AS

SET NOCOUNT ON;

SELECT
		[Region].[regionid],
	[Region].[regiondescription],
	[Region].[created_by],
	[Region].[created_date],
	[Region].[modified_by],
	[Region].[modified_date],
	[Region].[time_stamp]

FROM 
[Region]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

